package com.dc.designPattern._4_builder.extend.improve;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * Description: 指挥者_负责安排已有模块的执行顺序
 * @author: gdc
 * @date: 2021/6/21
 * @version 1.0
 */
public class Director {

    private List<String> sequence = Lists.newArrayList();

    private BenzBuilder benzBuilder = new BenzBuilder();

    private BmwBuilder bmwBuilder = new BmwBuilder();

    /**
     * A 类型的奔驰车模型（start -> stop）
     */
    public BenzModel getBenzModel_A(){
        // step 1 清理场景
        this.sequence.clear();

        // step 2 设置执行场景
        this.sequence.add("start");
        this.sequence.add("stop");

        this.benzBuilder.setSequence(sequence);

        // step 3 返回对象
        return (BenzModel) this.benzBuilder.build();
    }

    /**
     * B 类型的奔驰车模型（engineBoom -> start -> stop）
     */
    public BenzModel getBenzModel_B(){
        this.sequence.clear();

        this.sequence.add("engineBoom");
        this.sequence.add("start");
        this.sequence.add("stop");

        this.benzBuilder.setSequence(sequence);

        return (BenzModel) this.benzBuilder.build();
    }

    /**
     * C 类型的宝马车模型（alarm -> start -> stop）
     */
    public BmwModel getBmwModel_C(){
        this.sequence.clear();

        this.sequence.add("alarm");
        this.sequence.add("start");
        this.sequence.add("stop");

        this.bmwBuilder.setSequence(sequence);

        return (BmwModel) this.bmwBuilder.build();
    }

    /**
     * D 类型的宝马车模型（start -> alarm -> engineBoom -> stop）
     */
    public BmwModel getBmwModel_D(){
        this.sequence.clear();

        this.sequence.add("start");
        this.sequence.add("alarm");
        this.sequence.add("engineBoom");
        this.sequence.add("stop");

        this.bmwBuilder.setSequence(sequence);

        return (BmwModel) this.bmwBuilder.build();
    }
}
